package com.trkj.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.trkj.pojo.Emp;
import com.trkj.pojo.Notice;
import com.trkj.service.NoticeService;
import com.trkj.vo.NoticeVo;

/**
 * 通知申请Controller
 * @author 彭帅
 *
 */
@Controller
@Transactional
@SessionAttributes({"emp", "funcIds"})
/**
 * 填写通知申请表单
 * @author 彭帅
 *
 */
public class NoticeController {
	@Autowired
	NoticeService noticeService;
	
	/**
	 * 填写通知申请表单
	 * @return
	 */
	@RequestMapping("/to_notice")
	public String to_notice() {
		return "to_notice";
	}
	
	/**
	 * 获取通知信息
	 * @param model
	 * @return
	 */
	@RequestMapping("/get_notice")
	@ResponseBody
	public NoticeVo getNotice(Model model) {
		Emp emp = (Emp) model.asMap().get("emp");
		Integer empid = emp.getEmpId();
		return noticeService.noticeVo(empid);
	}
	
	/**
	 * 通知申请暂存
	 * @param notice
	 * @param empId
	 * @return
	 */
	@RequestMapping("/save_notice")
	@ResponseBody
	public boolean save_notice(Notice notice,Integer empId) {
		Integer isSave = noticeService.save_notice(notice, empId);
		if (isSave != 0) {
			return true;
		}
			return false;
	}
	

}
